package com.lwq.springbootdruid.controller;

import com.lwq.springbootdruid.annotation.MyLogAnnotation;
import com.lwq.springbootdruid.entity.MyLog;
import com.lwq.springbootdruid.entity.MyUser;
import com.lwq.springbootdruid.service.MyLogService;
import com.lwq.springbootdruid.service.MyUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author liwq
 * @description
 * @date 2021/7/13 14:50
 */
@RestController
@Slf4j
public class UserController {

    @Autowired
    private MyLogService myLogService;

    @Autowired
    private MyUserService myUserService;

    @GetMapping("/getAllUsers")
    @MyLogAnnotation("测试日志")
    public List<MyUser> getAllUsers() {
        List<MyUser> myUsers = myUserService.getAllUsers();
        log.info("myUsers:" + myUsers);
        return myUsers;
    }

    @GetMapping("/testMylog")
    @MyLogAnnotation("测试日志")
    public String testMylog() {
        log.info("controller testMylog=================================");
        myLogService.sayHello();
        return "hello";
    }

}
